package control;
import java.util.ArrayList;

import model.CustomerGroup;
import db.DBCustomerGroup;

public class CustomerGroupCtrl
{
	
	public CustomerGroupCtrl()
	{
		
	}
	
	public ArrayList<CustomerGroup> getAllCustomerGroups()
	{
		DBCustomerGroup dbCustGroup = new DBCustomerGroup();
		ArrayList<CustomerGroup> allCustGroup = new ArrayList<CustomerGroup>();
		allCustGroup = dbCustGroup.getAllCustomerGroups(false);
		return allCustGroup;
	}
	
	public CustomerGroup getCustomerGroupGroupType(String _groupType)
	{
		DBCustomerGroup dbCustomerGroup = new DBCustomerGroup();
		return dbCustomerGroup.getCustomerGroupGroupType(_groupType,false);
	}
	
	public CustomerGroup findByID(String _id)
	{
		DBCustomerGroup dbCustomerGroup = new DBCustomerGroup();
		return dbCustomerGroup.getCustomerGroupId(_id, false);
	}
	
	public void createCustomerGroup(int _id, String _groupType, double _discount) throws Exception
	{
		CustomerGroup toInsert = new CustomerGroup();
		toInsert.setId(_id);
		toInsert.setGroupType(_groupType);
		toInsert.setDiscount(_discount);
		DBCustomerGroup dbCustomerGroup = new DBCustomerGroup();
		dbCustomerGroup.insertCustomerGroup(toInsert);
	}
	
	public void updateCustomerGroup(int _id, String _groupType, double _discount)
	{
		CustomerGroup toUpdate = new CustomerGroup();
		toUpdate.setId(_id);
		toUpdate.setGroupType(_groupType);
		toUpdate.setDiscount(_discount);
		DBCustomerGroup dbCustomerGroup = new DBCustomerGroup();
		dbCustomerGroup.updateCustomerGroup(toUpdate);
	}
	
	public void deleteCustomerGroup(String _id)
	{
		DBCustomerGroup dbCustomerGroup = new DBCustomerGroup();
		dbCustomerGroup.deleteCustomerGroup(_id);
	}

}
